package cn.virens.web.components.spring.permission;

import java.util.ArrayList;
import java.util.Iterator;

public class PermissionNodeList extends ArrayList<PermissionNode> {
	private static final long serialVersionUID = 1120692622100234009L;

	@Override
	public boolean add(PermissionNode node) {
		// 尝试添加到下级
		Iterator<PermissionNode> iterator = iterator();
		while (iterator.hasNext()) {
			PermissionNode children = iterator.next();
			if (children.addChildren(node)) { return true; }
		}

		// 添加到当前层级
		return super.add(node);
	}
}